import { http } from "@/utils/http";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

/**
 设备巡检接口
 **/
// 查询设备巡检-巡检规则接口
export const queryInspectRule = (data?: object) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/checkRule/pageList", {
    data
  });
};
// 新增设备巡检-巡检规则接口
export const addInspectRule = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/checkRule/save", {
    data
  });
};
// 修改设备巡检-巡检规则接口
export const editInspectRule = (data?: object) => {
  return http.request("post", "/digitaltwins/api/v1/checkRule/update", {
    data
  });
};
// 删除设备巡检-巡检规则接口
export const deleteInspectRule = (data?: object) => {
  return http.request("get", `/digitaltwins/api/v1/checkRule/delByCheckRuleNo/${data}`, {
    data
  });
};
// 获取设备巡检-巡检规则详情接口
export const getInspectRule = (data?: object) => {
  return http.request("get", `/digitaltwins/api/v1/checkRule/getByCheckRuleNo/${data}`, {
    data
  });
};
// 删除设备巡检-巡检规则内容接口
export const deleteInspectRuleContent = (data?: object) => {
  return http.request("get", `/digitaltwins/api/v1/checkRuleContent/delById/${data}`, {
    data
  });
};
// 新增设备巡检-巡检规则关联设备拖拽排序
export const sortInspectEqpRelation = (data?: object) => {
  return http.request("get", "/digitaltwins/api/v1/checkRuleEqpRelation/dragSort", {
    data
  });
};
// 删除设备巡检-巡检规则编号删除设备
export const deleteInspectEqpCheckRuleNo = (data?: object) => {
  return http.request("get", `/digitaltwins/api/v1/checkRuleEqpRelation/delByCheckRuleNo/${data}`, {
    data
  });
};
// 保存设备巡检-巡检内容
export const saveInspectContent = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/checkRuleContent/saveOrUpdate`, {
    data
  });
};
// 删除设备巡检-巡检规则编号删除设备
export const deleteInspectContentEqpId = (data?: object) => {
  return http.request("get", `/digitaltwins/api/v1/checkRuleContentItem/delById/${data}`, {
    data
  });
};

// 设备巡检规则编号生成
export const generateCheckRuleNo = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/checkRule/generateCheckRuleNo`, {
    data
  });
};

// 设查询多个设备属性并按照设备id分组
export const queryByEquipmentIds = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/equipmentAttribute/queryByEquipmentIdsAndGroupByEqpId`, {
    data
  });
};

/**
 * 设备巡检--巡检计划接口
 */
//查询巡检计划
export const inspectPlanQueryPage = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/queryPage`, {
    data
  });
};
// 计划编码
export const getRuleCode = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/getRuleCode`, {
    data
  });
};
//巡检计划-取消
export const inspectPlanCancel = id => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/cancel/${id}`, {});
};
//巡检计划-删除-禁用
export const inspectPlanDel = ({ id }) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/del/${id}`, {});
};
//巡检计划-查询详情数据-根据id查详情
export const inspectPlanView = ({ id }) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/get/${id}`);
};
//巡检计划-查询详情数据-根据code查详情
export const inspectPlanViewByCode = ({ planCode }) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/getByCode/${planCode}`);
};
//巡检计划-新增数据
export const inspectPlanAdd = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/save`, {
    data
  });
};
//巡检计划-新增草稿数据
export const inspectPlanAddDraft = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/saveDraft`, {
    data
  });
};
//巡检计划-修改数据
export const inspectPlanUpdate = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/update`, {
    data
  });
};
//巡检计划-修改草稿数据
export const inspectPlanUpdateDraft = (data?: object) => {
  return http.request("post", `/digitaltwins/api/v1/inspectPlan/updateDraft`, {
    data
  });
};
